package com.learn.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.learn.project.annotation.DataSourceSelector;
import com.learn.project.domain.JobData;
import com.learn.project.enums.DBTypeEnum;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lijiajun
 * @date 2023/11/21
 */
@Mapper
public interface JobDataMapper extends BaseMapper<JobData> {
    /**
     * 获取任务数据列表
     *
     * @return list
     */
    @DataSourceSelector(DBTypeEnum.Slave)
    @Select("select * from job_test_data")
    List<JobData> getJobDataList();

    /**
     * 添加数据
     *
     * @param jobData 任务数据
     */
    @DataSourceSelector(DBTypeEnum.Master)
    @Insert("insert into job_test_data(job_name,job_class_name,type, created_at) values(#{jobName},#{jobClassName},#{type},now())")
    void saveJobData(JobData jobData);
}
